<template>
  <web-view :src="liveLink"></web-view>
</template>

<script>
import { getLiveInfo } from "@/api/index";
// import { twistStr } from "@/utils/handle";
import ShareMixin from '@/mixins/share';
export default {
  mixins: [ShareMixin],
  data() {
    return {
      liveId: "",
      personId: uni.getStorageSync("person-id").slice(2) || "",
      // linkBase: "https://m5.yl1001.com/marketing/download/download.html",
      // linkBase: "https://m5.yl1001.com/marketing/zhibo/index.html#/",
      // linkBase: "http://192.168.60.151:8082/#/",
    };
  },
  computed: {
    linkBase() {
      let kingKong = this.$indexKingKong(this.$imgBaseSelf);
      if (JSON.stringify(kingKong).indexOf("live") >= 0) {
        return "https://m5.yl1001.com/marketing/zhibo/index.html#/";
      } else {
        return "https://m5.yl1001.com/marketing/about/security.html";
      }
    },
    liveLink() {
      let platform = "h5";
      // #ifdef MP-WEIXIN
      platform = "mp";
      // #endif
      return `${this.linkBase}?fromtype=uni-${platform}&theme=${
        this.$theme
      }&live_id=${this.liveId}&person_id=${this.personId}&height=${
        getApp().globalData.viewHeight
      }`;
    },
  },
  onLoad(opt) {
    let title = opt.title;
    let kingKong = this.$indexKingKong(this.$imgBaseSelf);
    if (JSON.stringify(kingKong).indexOf("live") < 0) {
      title = "隐私政策";
    }
    uni.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: this.$primaryColor,
    });
    this.liveId = opt.id;
    if (title) {
      uni.setNavigationBarTitle({
        title: title,
      });
    } else {
      this.getLiveInfo();
    }

    this.shareTitle = this.title;
    this.sharePath = `/pagesSub/index/liveDetail/index?id=${this.liveId}&title=${this.title}`;
  },
  // onShareAppMessage() {
  //   return {
  //     title: this.title,
  //     path: `/pagesSub/index/liveDetail/index?id=${this.liveId}&title=${this.title}`,
  //   };
  // },
  // onShareTimeline() {
  //   return {
  //     title: this.title,
  //     path: `/pagesSub/index/liveDetail/index?id=${this.liveId}&title=${this.title}`,
  //   };
  // },
  methods: {
    getLiveInfo() {
      let param = {
        id: this.liveId,
      };
      getLiveInfo(param).then((res) => {
        if (+res.code === 200) {
          uni.setNavigationBarTitle({
            title: res.data.liveName,
          });
        }
      });
    },
  },
};
</script>

<style lang="scss">
.page-wrap {
  background: $uni-bg-color;
}
</style>

